package com.sino.business.service;
/**
 * Copyright (C)          : Sinodigital Tech. Co., Ltd. 
 * Project                : 专利项目申请 JDK version
 * used                   : jdk1.5.0_08 
 * Description            : 提供基本数据业务逻辑实现类
 * Version                : 1.0 
 * Date                   : 2008.2.20
 * Modification history   : 新建
 */
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.sino.bean.Area;
import com.sino.bean.Flzt;
import com.sino.bean.Hy;
import com.sino.bean.Qxkw;
import com.sino.bean.SysZhuanyema;
import com.sino.bean.Xk;
import com.sino.bean.Xkzl;
import com.sino.bean.Zltype;
import com.sino.bean.Zltype1;
import com.sino.business.IStaticDataService;
import com.sino.dao.IStaticDataDAO;
import com.sino.model.StaticModel;
import com.sino.model.ZhuanyemaModel;
import com.sino.util.SelectinoCreate;
import com.sino.util.SysParameter;

public class StaticDataServiceImp implements IStaticDataService {
	private IStaticDataDAO staticDataDAO;
	
	private static List hyList = null;
	private static List xkList = null;
	private static List zlTypeList = null;
	private static List zlType1List = null;
	private static List xkzlList = null;
	private static List areaList = null;
	private static List flztList = null;
	private static List qxkwList = null;
	
	/**
     * Description     	���������о�̬��ݵ�request�У�����ÿ��ʹ��
     * @param request   ������HttpServletRequest����
     */	
	public void setStaticRequest(HttpServletRequest request){
		request.setAttribute(SysParameter.AREALIST, this.findAreaList());
		request.setAttribute(SysParameter.FLZTLIST, this.findFlztList());
		request.setAttribute(SysParameter.HYLIST, this.findHyList());
		request.setAttribute(SysParameter.QXKWLIST, this.qxkwList);
		request.setAttribute(SysParameter.XKLIST, this.findXkList());
		request.setAttribute(SysParameter.XKZTLIST, this.findXkzlList());
		request.setAttribute(SysParameter.ZLTYPELIST, this.findZlTypeList());
	}
	/**
	 * Description 获得行业列表
	*/
	public List findHyList(){
		if(hyList == null){
			hyList = new ArrayList();
			List temp = this.getStaticDataDAO().findHyList();
			Iterator it = temp.iterator();
			Hy hy = null;
			while(it.hasNext()){
				hy = (Hy)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(hy.getId());
				staticModel.setName(hy.getName());
				hyList.add(staticModel);				
			}
		}
		return hyList;
	}
	/**
	 * Description 获得学科列表
	*/
	public List findXkList(){
		if(xkList == null){
			xkList = new ArrayList();
			List temp = this.getStaticDataDAO().findXkList();
			Iterator it = temp.iterator();
			Xk xk = null;
			while(it.hasNext()){
				xk = (Xk)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(xk.getId());
				staticModel.setName(xk.getName());
				xkList.add(staticModel);				
			}
		}
		return xkList;
	}
	/**
	 * Description 专利大类别列表
	*/
	public List findZlType1List(){
		if(zlType1List == null){
			zlType1List = new ArrayList();
			List temp = this.getStaticDataDAO().findZlType1List();
			Iterator it = temp.iterator();
			Zltype1 zltype1 = null;
			while(it.hasNext()){
				zltype1 = (Zltype1)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(zltype1.getId());
				staticModel.setName(zltype1.getName());
				zlType1List.add(staticModel);				
			}
		}
		return zlType1List;	
	}
	/**
	 * Description 专利类别列表
	*/
	public List findZlTypeList(){
		if(zlTypeList == null){
			zlTypeList = new ArrayList();
			List temp = this.getStaticDataDAO().findZlTypeList();
			Iterator it = temp.iterator();
			Zltype zltype = null;
			while(it.hasNext()){
				zltype = (Zltype)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(zltype.getId());
				staticModel.setName(zltype.getName());
				zlTypeList.add(staticModel);				
			}
		}
		return zlTypeList;
	}
	/**
	 * Description 专利类别列表==级联菜单
	*/
	public String findZlTypeListSelect(){
		SelectinoCreate select = new SelectinoCreate();
		return select.getSelectListLandong(this.findZlTypeList());
	}
	/**
	 * Description 获得学科种类列表
	*/
	public List findXkzlList(){
		if(xkzlList == null){
			xkzlList = new ArrayList();
			List temp = this.getStaticDataDAO().findXkzlList();
			Iterator it = temp.iterator();
			Xkzl xkzl = null;
			while(it.hasNext()){
				xkzl = (Xkzl)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(xkzl.getId());
				staticModel.setName(xkzl.getName());
				xkzlList.add(staticModel);				
			}
		}
		return xkzlList;
	}
	/**
	 * Description 获得国家/地区列表
	*/
	public List findAreaList(){
		if(areaList == null){
			areaList = new ArrayList();
			List temp = this.getStaticDataDAO().findAreaList();
			Iterator it = temp.iterator();
			Area area = null;
			while(it.hasNext()){
				area = (Area)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(area.getId());
				staticModel.setName(area.getName());
				areaList.add(staticModel);				
			}
		}
		return areaList;
	}
	/**
	 * Description 获得法律状态列表
	*/
	public List findFlztList(){
		if(flztList == null){
			flztList = new ArrayList();
			List temp = this.getStaticDataDAO().findFlztList();
			Iterator it = temp.iterator();
			Flzt flzt = null;
			while(it.hasNext()){
				flzt = (Flzt)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(flzt.getId());
				staticModel.setName(flzt.getName());
				flztList.add(staticModel);				
			}
		}
		return flztList;
	}
	/**
	 * Description 获得区县科委列表
	*/
	public List findQxkwList(){
		if(qxkwList == null){
			qxkwList = new ArrayList();
			List temp = this.getStaticDataDAO().findQxkwList();
			Iterator it = temp.iterator();
			Qxkw qxkw = null;
			while(it.hasNext()){
				qxkw = (Qxkw)it.next();
				StaticModel staticModel = new StaticModel();
				staticModel.setId(qxkw.getId());
				staticModel.setName(qxkw.getName());
				qxkwList.add(staticModel);				
			}
		}
		return qxkwList;
	}
	/**
	 * Description 获得专利类别--用于列表专利类别用
	*/
	public List findZlTypeList(String zlid){
		List zlTypeList = new ArrayList();
		List temp = null;
		if(zlid==null){
			temp = this.getStaticDataDAO().findZlTypeA();
		}else if(zlid.length()==1){
			temp = this.getStaticDataDAO().findZlTypeB(zlid);
		}else if(zlid.length()==3){
			temp = this.getStaticDataDAO().findZlTypeC(zlid);
		}
		Iterator it = temp.iterator();
		Zltype zltype = null;
		while(it.hasNext()){
			zltype = (Zltype)it.next();
			StaticModel staticModel = new StaticModel();
			staticModel.setId(zltype.getId());
			staticModel.setName(zltype.getName());
			zlTypeList.add(staticModel);
		}
		return zlTypeList;
	}
	/**
	 * Description 区县科委--用于显示区县科委类表用
	*/
	public List findQxkwList(String qxkwlb){
		List qxkwList = new ArrayList();
		List temp = null;
		if(qxkwlb==null){
			temp = this.getStaticDataDAO().findQxkwA();
		}else if(qxkwlb.length()==2){
			temp = this.getStaticDataDAO().findQxkwB(qxkwlb);
		}
		Iterator it = temp.iterator();
		Qxkw qxkw = null;
		while(it.hasNext()){
			qxkw = (Qxkw)it.next();
			StaticModel staticModel = new StaticModel();
			staticModel.setId(qxkw.getId());
			staticModel.setName(qxkw.getName());
			qxkwList.add(staticModel);
		}
		return qxkwList;
	}
	//-------------------------------------------接口
	public IStaticDataDAO getStaticDataDAO() {
		return staticDataDAO;
	}
	public void setStaticDataDAO(IStaticDataDAO staticDataDAO) {
		this.staticDataDAO = staticDataDAO;
	}
	public List<ZhuanyemaModel> findZhuanyema() {
		List<SysZhuanyema> ls=this.staticDataDAO.findZhuanyema();
		List<ZhuanyemaModel> list=new ArrayList<ZhuanyemaModel>();
		for(SysZhuanyema szy:ls)
		{
			ZhuanyemaModel zym=new ZhuanyemaModel();
			zym.setBm(szy.getBm());
			zym.setShM(szy.getShM());
			list.add(zym);
		}
		return list;
	}
}
